package com.truesai.entities.income;

import java.math.BigDecimal;
import java.sql.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import com.truesai.dto.CloseingAccountType;

/**
 * 结款总表<br/>
 * 需求分析<br/>
 * <strong>唯一性:</strong>采购入库or销售，操作日期
 * @author XuLian
 *
 */
@Entity
@NamedQueries(
{
        @NamedQuery(name = ClosingAccount.ALL, query = "Select ca from ClosingAccount ca"),
        @NamedQuery(name = ClosingAccount.BY_OPID, query = "Select ca from ClosingAccount ca where ca.opId = :opid"),
        @NamedQuery(name = ClosingAccount.BY_ID, query = "Select ca from ClosingAccount ca where ca.id = :id") })
@Table(name = "ClosingAccounts")
public class ClosingAccount {
	public static final String ALL = "ClosingAccount.all";

    public static final String BY_OPID = "ClosingAccount.byOpId";

    public static final String BY_ID = "ClosingAccount.byId";
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    /**采购入库id or 销售id*/
    @Column
    private Long opId;
    
    /**操作日期*/
    @Column
    private Date opDate;
    
    /**利润*/
    @Column
    @Enumerated(EnumType.ORDINAL)
    private CloseingAccountType closeType;
    
    /**总货款*/
    @Column
    private BigDecimal totalMoney;
    
    /**已结货款*/
    @Column
    private BigDecimal closedMoney;
    
    /**剩余未货款*/
    @Column
    private BigDecimal leftMoney;
    
    public ClosingAccount() { }
    
    public ClosingAccount(Long opId, Date opDate, CloseingAccountType closeType,
    		BigDecimal closedMoney, BigDecimal leftMoney) {
    	this.opId = opId;
    	this.opDate = opDate;
    	this.closeType = closeType;
    	this.closedMoney = closedMoney;
    	this.leftMoney = leftMoney;
    }

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getOpId() {
		return opId;
	}

	public void setOpId(Long opId) {
		this.opId = opId;
	}

	public Date getOpDate() {
		return opDate;
	}

	public void setOpDate(Date opDate) {
		this.opDate = opDate;
	}

	public CloseingAccountType getCloseType() {
		return closeType;
	}

	public void setCloseType(CloseingAccountType closeType) {
		this.closeType = closeType;
	}

	public BigDecimal getTotalMoney() {
		return totalMoney;
	}

	public void setTotalMoney(BigDecimal totalMoney) {
		this.totalMoney = totalMoney;
	}

	public BigDecimal getClosedMoney() {
		return closedMoney;
	}

	public void setClosedMoney(BigDecimal closedMoney) {
		this.closedMoney = closedMoney;
	}

	public BigDecimal getLeftMoney() {
		return leftMoney;
	}

	public void setLeftMoney(BigDecimal leftMoney) {
		this.leftMoney = leftMoney;
	}
    
}
